package com.wmh.baseservice.operationaid.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wmh.baseservice.common.mybatisplus.structure.LambdaQueryWrapperX;
import com.wmh.baseservice.operationaid.entity.KeyWordUsageRecord;

import java.util.List;

/**
 * @author dongaolong
 * @description 针对表【operation_aid_key_word_usage_record】的数据库操作Mapper
 * @createDate 2023-06-20 15:27:56
 * @Entity com.wmh.baseservice.operationAid.entity.KeyWordUsageRecord
 */
public interface KeyWordUsageRecordMapper extends BaseMapper<KeyWordUsageRecord> {

    /**
     * 获取没有分组的关键词记录
     * @param categoryName 品类
     * @param adId 管理员 id
     * @return
     */
    default List<KeyWordUsageRecord> selectListNoGroup(String categoryName, Long adId) {
        return selectList(new LambdaQueryWrapperX<KeyWordUsageRecord>()
                .eq(KeyWordUsageRecord::getCategoryName,categoryName)
                .eq(KeyWordUsageRecord::getAdId,adId)
                .isNull(KeyWordUsageRecord::getGroupId)
        );
    }

    default List<KeyWordUsageRecord> selectList(String categoryName, Long adId, Long groupId) {
        return selectList(new LambdaQueryWrapperX<KeyWordUsageRecord>()
                .eq(KeyWordUsageRecord::getCategoryName,categoryName)
                .eq(KeyWordUsageRecord::getAdId,adId)
                .eq(KeyWordUsageRecord::getGroupId,groupId)
        );
    }

}




